import Taro from '@tarojs/taro'
import { getDetailsById, getCombo } from './service';

export default {

  namespace: 'template',

  state: {
  },

  effects: {
    * init({payload:id}, { call, put }) {
      console.log('template effects id',id);
      console.log(typeof(id));
      const details = yield call(getDetailsById,id);
      console.log('template effects details',details);
      const combo = yield call(getCombo,details.id);
      console.log('template effects combo',combo);
      yield put({
        type:'save',
        payload: {details,combo:combo.list}
      });
    },

  },

  reducers: {
    save(state, { payload }) {
      console.log('template reducers payload',payload);
      return {
        ...state,
        ...payload
      };
    },
  },
};
